<?php
namespace app\portal\model;

use think\Model;

class HouseData extends Model
{
  protected $name = 'house_data';

  public function setSlidesAttr($value)
  {
      return json_encode($value);
  }

  public function getSlidesAttr($value) {
    $data = json_decode($value, true);
    // foreach ($data as $key => $value) {
    //   if (!preg_match('/^http|^\/\//', $value['url'])) {
    //     $data[$key]['url'] = 'https://www.youjushidai.top/upload/' . $value['url'];
    //   }
    // }
    return $data;
  }

  public function setPositionPictureAttr($value)
  {
      return json_encode($value);
  }

  public function getPositionPictureAttr($value) {
    $data = json_decode($value, true);
    // foreach ($data as $key => $value) {
    //   if (!preg_match('/^http|^\/\//', $value['url'])) {
    //     $data[$key]['url'] = 'https://www.youjushidai.top/upload/' . $value['url'];
    //   }
    // }
    return $data;
  }

  public function getProcessAttr($value) {
    return explode(PHP_EOL, $value);
  }

}
